//
//  DetectionHeaderView.m
//  INMOTION
//
//  Created by Kyle on 14-4-21.
//  Copyright (c) 2014年 Inmotion. All rights reserved.
//

#import "DetectionHeaderView.h"
#import "IMTConfig.h"
#import "KSLanguageManager.h"
#import "AppTypeTool.h"

@implementation DetectionHeaderView

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code

    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)drawArcLine {
    UIBezierPath *redPath = [UIBezierPath bezierPath];
    [redPath addArcWithCenter:CGPointMake(60, 56) radius:39 startAngle:0 endAngle:M_PI * 2 clockwise:YES];

    self.arcLayer = [CAShapeLayer layer];
    self.arcLayer.path = redPath.CGPath;
    self.arcLayer.fillColor = [UIColor clearColor].CGColor;
    self.arcLayer.strokeColor = [AppTypeTool getThemeColor].CGColor;
    self.arcLayer.lineWidth = 3;
    self.arcLayer.frame = self.frame;
    [self.layer addSublayer:self.arcLayer];
//    [self drawLineAnimation:self.arcLayer];
}

- (void)drawLineAnimation:(CALayer *)layer {
    CABasicAnimation *bas = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
    bas.duration = 10;
    bas.fromValue = [NSNumber numberWithInteger:0];
    bas.toValue = [NSNumber numberWithInteger:1];
    [layer addAnimation:bas forKey:@"key"];
}

- (void)drawLineAnimationWithduration:(NSUInteger)duration {
    CABasicAnimation *bas = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
    bas.duration = duration;
    bas.fromValue = [NSNumber numberWithInteger:0];
    bas.toValue = [NSNumber numberWithInteger:1];
    [self.arcLayer addAnimation:bas forKey:@"key"];
}

- (void)resetArcLine {
    [self.arcLayer removeFromSuperlayer];
    self.arcLayer = nil;
}

@end
